<?php
class LoginFilter extends CFilter{
	protected function preFilter($filterChain)
    {
       
    	// logic being applied before the action is executed
        if(yii::app()->user->isGuest){
        	$url;
        	$con_id=$filterChain->controller->getId();
        	if($con_id=='site'){
        		$url=array('site/login');//直接访问的外部窗口直接转入site/login
        	}
        	else{
        		$url=array('site/to_login','message'=>'1');//直接访问的内部窗口通过to_login转入site/login
        	}
        	$filterChain->controller->redirect($url);
        	return false;
        }
    	return true; // false if the action should not be executed
    }
 
    protected function postFilter($filterChain)
    {
        // logic being applied after the action is executed
    }
	
}
?>